<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<head>
    <title>My Facelets Page</title>
    <meta http-equiv="keywords" content="enter,your,keywords,here"/>
    <meta http-equiv="description"
          content="A short description of this page."/>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

    <!--<link rel="stylesheet" type="text/css" href="styles.css">-->
</head>
<body>
<ui:composition template="General.xhtml">
    <ui:define name="title">
        <h:outputText value="讨论主题 - #{threadDetail.thread.title}"/>
    </ui:define>
    <ui:define name="content">
        <ui:include src="TalkEditPopup.xhtml"></ui:include>
        <ui:include src="SendMessagePopup.xhtml"></ui:include>
        <ui:include src="AdminFilePanel.xhtml"></ui:include>
        <h:panelGrid style="width:100%;" cellpadding="0" cellspacing="0">
            <h:panelGrid columns="5">
                <h:outputLink value="ZoneList.jspx" styleClass="topNav1">
                    <h:outputText value="讨论"/>
                </h:outputLink>
                <h:outputText value=">>"/>
                <h:outputLink styleClass="topNav1"
                              value="ThreadList.jspx?id=#{threadDetail.thread.zone.id}">
                    <h:outputText value="#{threadDetail.thread.zone.name}"/>
                </h:outputLink>
                <h:outputText value=">>"/>
                <h:outputText value="#{threadDetail.thread.title}" styleClass="mark"/>
            </h:panelGrid>
            <p:separator/>
            <h:panelGrid columns="2" columnClasses="w50,w50" style="width:100%">
                <h:outputText value="浏览量：#{threadDetail.thread.readCount}" styleClass="mark"></h:outputText>
            </h:panelGrid>

            <p:dataTable id="talks" widgetVar="talks" value="#{threadDetail.talks}" rows="10" rowIndexVar="row"
                         var="talk" paginator="true" paginatorPosition="bottom" style="padding: 0px;">
                <f:facet name="header">
                    <h:outputLink
                            value="ThreadDetail.jspx?id=#{threadDetail.thread.id}">
                        <h:outputText value="主题：#{threadDetail.thread.title}"/>
                    </h:outputLink>
                </f:facet>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="作者"></h:outputText>
                    </f:facet>

                    <div style="margin: 0 auto;text-align: center;border: 1px solid #cccccc;width:160px;padding: 10px 2px 10px 2px;">
                        <h:outputLink target="_blank" value="UserCenter.jspx?id=#{talk.genBy.id}" styleClass="header">
                            <h:outputText value="#{talk.genBy.username}"/>
                        </h:outputLink>
                        <h:outputText value="（版主）" escape="false"
                                      rendered="#{fn:contains(talk.thread.zone.magsStr,talk.genBy.username)}"
                                      styleClass="mark"></h:outputText>

                        <hr/>
                        <p:graphicImage
                                value="#{talk.genBy.picUrl==''?'/resources/images/user_model.gif':talk.genBy.picUrl}"
                                style="width:120px;height:120px;margin: 10px 0px 10px 0px;"/><br/>

                        <h:panelGrid style="text-align: left;margin: 0 auto;width:90%;" columns="2" cellspacing="0"
                                     styleClass="threadColumn generalInfo">
                            <h:outputText value="性别" escape="false"></h:outputText>
                            <h:outputText value="#{talk.genBy.gender}" escape="false"></h:outputText>
                            <h:outputText value="年龄" escape="false"></h:outputText>
                            <h:outputText value="#{talk.genBy.age}" escape="false"></h:outputText>
                            <h:outputText value="帖子" escape="false"></h:outputText>
                            <h:outputLink target="_blank" value="UserTalkList.jspx?id=#{talk.genBy.id}"
                                          styleClass="operation">
                                <h:outputText value="#{talk.genBy.talkCount}" escape="false"></h:outputText>
                            </h:outputLink>
                            <h:outputText value="积分" escape="false"></h:outputText>
                            <h:outputText value="#{talk.genBy.score}" escape="false"></h:outputText>
                            <h:outputText value="最后登录" escape="false"></h:outputText>
                            <h:outputText value="#{talk.genBy.regTime}">
                                <f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
                            </h:outputText>
                            <h:outputLink value="UserCenter.jspx?id=#{talk.genBy.id}" styleClass="operation">
                                <h:outputText value="查看资料"/>
                            </h:outputLink>
                            <p:commandLink value="发送消息" action="#{clientSendMsg.begainSend(talk.genBy.id)}"
                                           rendered="#{clientSession.ifLogin}" onclick="msg1.show();"
                                           styleClass="operation"/>
                        </h:panelGrid>
                    </div>
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="正文"></h:outputText>
                    </f:facet>
                    <h:panelGrid style="width:700px;" styleClass="threadColumn"
                                 cellpadding="0" cellspacing="0">
                        <h:panelGrid
                                style="width:700px;border-bottom: 1px solid gray;height:35px;"
                                cellpadding="0" cellspacing="0">
                            <h:panelGroup>
                                <h:outputText value="#{row+1}#" styleClass="mark"
                                              style="margin:0px 15px 0px 5px;"></h:outputText>
                                <h:outputText value="#{talk.genTime}"
                                              style="margin:0px 15px 0px 5px;" styleClass="generalInfo">
                                    <f:convertDateTime pattern="发表时间：yyyy-MM-dd HH:mm" type="both"
                                                       timeZone="GMT+8"/>
                                </h:outputText>

                                <h:outputText rendered="#{talk.genTime!=talk.lastEditTime}" styleClass="generalInfo"
                                              value="#{talk.lastEditTime}" style="margin:0px 15px 0px 5px;">
                                    <f:convertDateTime pattern="最后修改：yyyy-MM-dd HH:mm" type="both"
                                                       timeZone="GMT+8"/>
                                </h:outputText>

                                <h:outputText value="IP：#{talk.ip}（#{talk.ipAddr}）"
                                              styleClass="generalInfo"></h:outputText>

                            </h:panelGroup>
                        </h:panelGrid>

                        <h:panelGrid
                                style="width:700px;height:280px;padding: 3px 3px 3px 3px;"
                                cellpadding="0" cellspacing="0">
                            <h:outputText value="#{talk.content}" escape="false" rendered="#{talk.ifPub}"
                                          styleClass="talkContent"></h:outputText>
                            <h:outputText value="此发言已被屏蔽" escape="false" rendered="#{!talk.ifPub}"
                                          styleClass="talkContent"></h:outputText>
                        </h:panelGrid>
                        <script language="javascript">
                            function reply() {
                                $("html,body").animate({scrollTop: $("#aaa").offset().top}, 1000);
                            }
                        </script>
                        <h:panelGrid
                                style="width:700px;border-top: 1px solid gray;height:35px;"
                                cellpadding="0" cellspacing="0">
                            <h:panelGroup>
                                <p:commandLink action="#{threadDetail.toSomeone(talk.genBy.username)}" value="回复"
                                               rendered="#{clientSession.ifLogin and talk.ifPub}"
                                               update=":myForm:add_new" oncomplete="reply();" styleClass="operation"/>
                                &nbsp;&nbsp;
                                <p:commandLink action="#{threadDetail.quote(talk.content)}" value="引用"
                                               rendered="#{clientSession.ifLogin and talk.ifPub}"
                                               update=":myForm:add_new" oncomplete="reply();" styleClass="operation"/>
                                &nbsp;&nbsp;
                                <h:outputLink target="_blank" value="UserCenter.jspx?id=#{talk.genBy.id}"
                                              styleClass="operation">
                                    <h:outputText value="主页"></h:outputText>
                                </h:outputLink>
                                &nbsp;&nbsp;
                                <p:commandLink
                                        rendered="#{talk.genBy.username==clientSession.usr.username}"
                                        styleClass="operation"
                                        value="编辑" onclick="editTalk1.show();"
                                        action="#{threadDetail.edit(talk.id)}">
                                </p:commandLink>
                                &nbsp;&nbsp;
                                <p:commandLink value="屏蔽"
                                               rendered="#{fn:contains(talk.thread.zone.magsStr,clientSession.usr.username) and (talk.ifPub and clientSession.ifLogin)}"
                                               action="#{threadDetail.block(talk.id)}" update=":myForm:talks"
                                               styleClass="operation">
                                </p:commandLink>
                                <p:commandLink value="解屏蔽"
                                               rendered="#{fn:contains(talk.thread.zone.magsStr,clientSession.usr.username) and (!talk.ifPub and clientSession.ifLogin)}"
                                               action="#{threadDetail.unblock(talk.id)}" update=":myForm:talks"
                                               styleClass="operation">
                                </p:commandLink>
                                &nbsp;&nbsp;
                                <p:commandLink value="删除"
                                               rendered="#{row!=0 and (fn:contains(talk.thread.zone.magsStr,clientSession.usr.username) and clientSession.ifLogin)}"
                                               action="#{threadDetail.del(talk.id)}" update=":myForm:talks"
                                               styleClass="operation">

                                </p:commandLink>


                            </h:panelGroup>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:column>
            </p:dataTable>
            <p:separator/>
            <p:outputPanel autoUpdate="true">
                <h:panelGrid rendered="#{clientSession.ifLogin}">
                    <h:panelGroup>
                        <a id="aaa" name="aaa"/>
                        <h:panelGrid columns="2" style="width:200px;">
                            <h:outputLink value="ClientListFile.jspx" styleClass="common" target="_blank">
                                <h:outputText value="上传文件"></h:outputText>
                            </h:outputLink>
                            <p:commandLink value="选择个人文件" action="#{clientListFile.synDB}" styleClass="common"
                                           update="AdminFilePanel" oncomplete="AdminFilePanel.show();return false"/>

                        </h:panelGrid>

                        <p:editor id="add_new" widgetVar="add_new" value="#{threadDetail.newTalk.content}"
                                  width="700"></p:editor>
                        <h:outputText value="注：本编辑器会验证输入内容，从其它网页或word直接拷贝的内容请点按钮“Paste as text”，或用记事本过滤掉格式。"
                                      style="color:green;"/>
                    </h:panelGroup>
                    <h:panelGroup>
                        <p:commandButton value="回复" action="#{threadDetail.addNewTalk}"
                                         oncomplete="talks.getPaginator().setPage(#{threadDetail.pageCount-1})"
                                         update=":myForm:talks">
                        </p:commandButton>
                    </h:panelGroup>


                </h:panelGrid>
            </p:outputPanel>
        </h:panelGrid>

    </ui:define>


</ui:composition>
</body>
</html>
